<?php
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";

   $strSql="select max(id)+1 as id  from PROVINCIA";
   $oConexion = new Conexion($MIES["motor_base"], $MIES["db_usuario"], $MIES["db_password"],
           $MIES["basedatos"], $MIES["servidor"], $MIES["flags"], $MIES["encoding"]);
   if(!$oConexion->EjecutarQuery($strSql)){
      $strERROR=1;
      $err=0;
   }
   $MaxId=$oConexion->getData("NUM");
   $MaxId = $MaxId[0][0];
   if(is_null($MaxId))
       $MaxId = 1;
   $oConexion->liberarResultado();
   $oConexion->Cerrar();

   $strSql="select * from PROVINCIA order by des";
   $oConexion = new Conexion($MIES["motor_base"], $MIES["db_usuario"], $MIES["db_password"],
           $MIES["basedatos"], $MIES["servidor"], $MIES["flags"], $MIES["encoding"]);

    if(!$oConexion->EjecutarQuery($strSql)){
        echo $oConexion->getErrorMessage();
      $strERROR=1;
      $err=0;
    }

   $arrData=$oConexion->getData("NUM");

   $oConexion->liberarResultado();
   $oConexion->Cerrar();

?>

<html>
<head>
<title>MIES-WORKFLOW</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
</head>

<body leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">
<p align="center" class="SoloStyle_TituloPaginas">Tabla de Provincias</p>
      <form name="frmIngreso" action= "trn_GrabaProvincia.php" method="POST">
<input type="hidden" name="opc" value="C">

  <table border="0" width="70%" align="center">
      <tr>
      <td class="SoloStyle_Etiqueta"><b>Id</b></td>
      <td class="SoloStyle_Texto"><?php echo $MaxId; ?><input type="hidden" maxlenght="50" size="50" name="HidId" class="texto" value="<?php echo $MaxId; ?>"></td>
    </tr>
    <tr>
      <td class="SoloStyle_Etiqueta"><b>Nueva Provincia</b></td>
      <td><input type="text" maxlenght="50" size="50" name="TxtDesc" class="SoloStyle_Texto"></td>
    </tr>
  </table>
          <br><center>
          <input type="button" name="CmdGrabar" value="Grabar" class="SoloStyle_Boton" onClick="Submit_Form(document.frmIngreso)"></center>

           </form>
  <table width="40%" border="0" align="center">
  <tr class="SoloStyle_Etiqueta">
    <td width="80%">Provincias</td>
    <td width="20%">Acci&oacute;n</td>
  </tr>
  <?php for($i=0; $i < count($arrData); $i++ ) {
      $clase = "SoloStyle_Texto";
        if ($i%2 == 0 ) $clase = "SoloStyle_Grid"; ?>
  <tr class="<?php echo $clase; ?>">
     <td><?php echo $arrData[$i][1]; ?></td>

    <td><a href= "trn_GrabaProvincia.php?id=<?php echo $arrData[$i][0]; ?>&ds=<?php echo $arrData[$i][1]; ?>&opc=M">
	<img src='iconos/soloico_modificar.gif' alt='Modificar' width="23" height="19" border='0' style='cursor:hand' ></a>&nbsp;
	    <a href="#" onClick="Comprobar('trn_GrabaProvincia.php?id=<?php echo $arrData[$i][0]; ?>&ds=<?php echo $arrData[$i][1]; ?>&opc=E')">
		<img src='iconos/soloico_eliminar.gif' alt='Borrar Campos' width="23" height="19" border='0' style='cursor:hand'></a></td>
  </tr>
  <?php } ?>
</table>
</body>
</html>

<SCRIPT type="text/JavaScript" src="PHPMailer/fun_generales.js"></SCRIPT>

 <script type="text/JavaScript">

function Window_Onload(){
var Mensaje;
    Mensaje = "<?php echo $_REQUEST["des"] ;?>";
    if ("<?php echo $_REQUEST["MiError"] ;?>"  != ""){

          if ("<?php echo $_REQUEST["MiError"]; ?>" == "0"){
             //Call Msgbox (, 64, "Aplicaci�n")
             alert(acentos("Operación OK"));
          }else{
             //Call Msgbox (Mensaje, 16, "Aplicaci�n")
             alert(acentos(Mensaje));
          }

    }
}

function Comprobar(pagina){
    //var conf = msgbox("Confirma Eliminar", VBOKCANCEL + VBQUESTION,"SoloPortal")
    var conf = confirm("Confirma Eliminar");
        if (conf)
	   window.location.href = pagina;
}

</script>